package cn.kuick.iplocation.jdk_proxy_study;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Created by Administrator on 2016/11/29.
 */
public class DoMain {
    public static void main(String[] args){
        ConcreteClass concreteClass = new ConcreteClass();
        InvocationHandler invocationHandler = new ProxyHandler(concreteClass);

        TargetInterface targetInterface = (TargetInterface) Proxy.newProxyInstance(concreteClass.getClass().getClassLoader(),
                concreteClass.getClass().getInterfaces(), invocationHandler);

        int i = targetInterface.targetMethodA(5);
        System.out.println("i= " + i);

        int j = targetInterface.targetMethodB(15);
        System.out.println("j= " + j);

    }
}
